import pygame, sys, math, random

from Block import Block
#PU: Speed

class PowerUp(Block):
    def __init__(self, pos, blocksize):
        types = ["Speed"]
        self.type = types[random.randint(0, len(types)-1)]
        if self.type == "Speed":
            image = "rsc/PowerUp/Speed.png"
        print image
        Block.__init__(self, image, pos, blocksize)
        
        self.image = pygame.transform.scale(self.image, [blocksize[0]/2, blocksize[1]/2])

        self.touched = True
        self.lifetime = 1000
    
    def update(*args):
        self = args[0]
        self.speedx = args[2]
        self.speedy = args[3]
        self.scrollingx = args[4]
        self.scrollingy = args[5]
        self.move()
        
        if self.lifetime > 0:
            self.lifetime -= 1
        else:
            self.kill()
        
    def move(self):
        if self.scrollingx:
            self.x -= self.speedx
        if self.scrollingy:
            self.y -= self.speedy
            
        self.rect.center = (round(self.x), round(self.y))
        